package server;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.*;

/**
 *
 * @author berthise
 */
public class Message {


    private int type;
    private String src;
    private String dest;
    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getDest() {
        return dest;
    }

    public void setDest(String dest) {
        this.dest = dest;
    }

    public String getSrc() {
        return src;
    }

    public void setSrc(String src) {
        this.src = src;
    }

    public Message() {
    }

    public Message(int type, String src, String dest, String message) {
        this.type = type;
        this.src = src;
        this.dest = dest;
        this.message = message;
    }
    public void writeMessage(int type, String src, String dest, String message) {
        this.type = type;
        this.src = src;
        this.dest = dest;
        this.message = message;
    }

    public void sendMessage(DataOutputStream sortie) {
        try {
            sortie.writeInt(type);
            sortie.writeUTF(src);
            sortie.writeUTF(dest);
            sortie.writeUTF(message);
        } catch (Exception e) {
        }
    }

    public void readMessage(DataInputStream entree) {
        try {
            type = entree.readInt();
            src = entree.readUTF();
            dest = entree.readUTF();
            message = entree.readUTF();
        } catch (Exception e) {
        }
    }
}
